package servlet;

import server.Request;
import server.Response;

/**
 * @author lbq
 * @version 1.0
 * @date 2021/1/22 21:11
 */
public abstract class HttpServlet implements Servlet {

    public abstract void doGet(Request request, Response response) throws Exception;

    public abstract void doPost(Request request, Response response) throws Exception;

    @Override
    public void service(Request request, Response response) throws Exception {
        String method = request.getMethod();
        switch (method.toLowerCase()) {
            case "post":
                doPost(request, response);
                break;
            case "get":
                doGet(request, response);
                break;
            default:
                break;
        }
    }
}
